HAL SDIO migration: List of applicable concepts

This section provides information about the HAL SDIO applicable architecture concepts.

HAL SDIO concepts

Concept

Description here

Separation of initialization and configuration functions

The initialization has been split into separate init and config functions:

  • HAL_SDIO_Init(): initializes the handle and links it to an SDIO instance.

  • HAL_SDIO_SetConfig(): sets the configuration for the SDIO peripheral.

Removal and conversion of init structure to configuration structure

The init structure has been removed from the handle and converted into hal_sdio_config_t structure.

Renaming of the handle structure

The handle structure has been renamed to hal_sdio_handle_t instead of SDIO_HandleTypeDef.

Renaming unitary init structures

The structure SDIO_InitTypeDef is no longer available and has been replaced by hal_sdio_config_t.

Remove MspInit and MspDeInit callbacks

hal_sdio_MspInit() and hal_sdio_MspDeInit() are no longer available, they are replaced by a user sequence to initialize and configure the SDIO.

Unitary configuration APIs

New APIs are introduced to individually set and get specific SDIO configuration parameters, allowing for more granular control and flexibility: HAL_SDIO_SetDataTimeout(), HAL_SDIO_GetDataTimeout().

Individual callback registration APIs replace global register and unregister functions

HAL2 provides individual register APIs for each callback. Unregister Callback APIs have been removed; the user can simply re-register the default weak callbacks when needed.

Removal of hardware-related macros in HAL2

HAL public macros have been removed. The SDIO driver does not have an LL, the HAL2 driver provides equivalent static inline APIs of the HAL1 macros.

Revised and optimized HAL API status returns

The HAL SDIO functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_TIMEOUT: in case of a user timeout.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL SDIO driver have been removed and replaced by _t.

Replaced nonmodifiable pointers with const keywords

Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable.

Assertion implementation and usage in HAL1

The parameters and states are checked using ASSERT_DBG_STATE and ASSERT_DBG_PARAM macros.

Refactor the HAL inclusion model.

HAL2 introduces a more structured and flexible inclusion model compared to HAL1, with a new entry point, conditional flags for module activation, consolidation of extension APIs. User configuration is propagated through dedicated header files.

Rename LL core drivers to stm32_ppp_core.h/.c to avoid confusion with user LL drivers.

LL core driver have been renamed from stm32tnxx_ll_sdmmc.h/.c to stm32tnxx_sdmmc_core.h/.c.

Add HAL PPP Services for Drivers with Handle to Retrieve Corresponding Peripheral Clock Frequency.

HAL SDIO provides a new API to retrieve clock frequency HAL_SDIO_GetClockFreq()

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including SDIO instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL resources and data structures are now prefixed with HAL_SDIO for improved clarity and consistency.